home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Pictures / TIFF / Tiff Utilties / Tiff Window DEMO / menu selection.c < prev    next >
C/C++ Source or Header  |  1990-02-15  |  2KB  |  86 lines

  1. #include "my color.h"
  2.  
  3.  
  4. /*Execute Item specified by mResult, the result of MenuSelect*/
  5. DoCommand(mResult)
  6. long        mResult;
  7.  
  8. {
  9.     short        theItem;        /*menu item number from mResult low-order word*/
  10.     short        theMenu;        /*menu number from mResult high-order word*/
  11.     char        name[256];    /*desk accessory name*/
  12.  
  13.  
  14.     theItem = LoWord(mResult);            /*call Toolbox Utility routines to set */
  15.     theMenu = HiWord(mResult);            /* menu item number and menu number*/
  16.     
  17.     switch (theMenu)                            /*switch on menu ID*/
  18.     {
  19.         case appleID:
  20.             if (theItem == aboutItem)
  21.                 DoAboutBox();
  22.             else
  23.             {                                                
  24.                 GetItem(myMenus[appleM],theItem,name);
  25.                 /*GetPort (&savedPort);*/
  26.                 scrapErr = ZeroScrap(); 
  27.                 (void) OpenDeskAcc(name);
  28.                 EnableItem (myMenus [editM],0);
  29.                 /*SetPort (savedPort);*/
  30.                 if (FrontWindow() != nil)
  31.                 {
  32.                     EnableItem (myMenus [fileM], closeItem);
  33.                     EnableItem (myMenus [editM], undoItem);
  34.                 } /*if FrontWindow*/
  35.                 menusOK = false;
  36.             }    /*if theItem...else*/
  37.             break;
  38.         case fileID:
  39.             switch (theItem) 
  40.             {
  41.                 case newItem:
  42.                     OpenWindow();
  43.                     break;
  44.                 case closeItem:
  45.                     if (((CWindowPeek)FrontWindow())->windowKind < 0)
  46.                         CloseDeskAcc(((CWindowPeek)FrontWindow())->windowKind);
  47.                         /*if desk acc window, close it*/
  48.                     else 
  49.                         KillWindow(FrontWindow());
  50.                         /*if it's one of mine, blow it away*/
  51.                     break;
  52.                 case quitItem:
  53.                     doneFlag = true; /*quit*/
  54.                 break;
  55.             } /*switch theItem*/
  56.             break;
  57.  
  58.          case editID:
  59.                 if (!SystemEdit(theItem-1))
  60.                         switch (theItem)     /*switch on menu item number*/
  61.                         {
  62.                             case cutItem:
  63.                                 break;
  64.                             case copyItem:
  65.                                 break;
  66.                             case pasteItem:
  67.                                 break;
  68.                             case clearItem:    
  69.                                 break;
  70.                         }    /*switch theItem*/
  71.                 break;
  72.  
  73.         case colorID:
  74.             change_color(theItem, (CWindowPtr)FrontWindow());
  75.             break;
  76.         
  77.         case controlID:
  78.             change_control_color(theItem, (CWindowPtr)FrontWindow());
  79.             break;
  80.  
  81.     }    /*switch theMenu*/
  82.     HiliteMenu(0);
  83.  
  84. }  /*DoCommand*/
  85.  
  86.